package com.waa.gulimall.gulimallsearch.controller;

import com.waa.gulimall.gulimallsearch.service.MallSearchService;
import com.waa.gulimall.gulimallsearch.vo.SearchParam;
import com.waa.gulimall.gulimallsearch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class SearchController {
@Autowired
private MallSearchService mallSearchService;
@GetMapping("/list.html")
public String listPage(SearchParam param, Model model, HttpServletRequest request){
    //
    final String queryString = request.getQueryString();
    param.set_queryString(queryString);
    //根据传递来的页面参数去es中查询数据
    final SearchResult result = mallSearchService.search(param);
    model.addAttribute("result",result);
    return "list";
}
}
